/**
 * 
 */
package org.mips.Sirius.components;

import java.util.ArrayList;

import com.google.android.maps.GeoPoint;

/**
 * @author Alessandro Represents a transport Stop
 * 
 */
public class StopPoint {

	private String reference;
	private String name;
	private GeoPoint coordinates;
	private ArrayList<Line> lines;
	private StopMonitoring lastMonitoring;

	public StopMonitoring getLastMonitoring() {
		return lastMonitoring;
	}

	public void setLastMonitoring(StopMonitoring lastMonitoring) {
		this.lastMonitoring = lastMonitoring;
	}

	public void setLines(ArrayList<Line> lines) {
		this.lines = lines;
	}

	public ArrayList<Line> getLines() {
		return lines;
	}

	public String getReference() {
		return reference;
	}

	public void setReference(String reference) {
		this.reference = reference;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public GeoPoint getCoordinates() {
		return coordinates;
	}

	public void setCoordinates(GeoPoint coordinates) {
		this.coordinates = coordinates;
	}

	/*
	 * Constructors
	 */
	public StopPoint(String reference, String name, int latitude, int longitude) {
		this.name = name;
		this.coordinates = new GeoPoint(latitude, longitude);
		this.reference = reference;
	}

	public StopPoint(String reference, String name) {
		this(reference, name, 0, 0);
	}

	@Override
	public String toString() {
		return name + "(" + reference + ")" + " ["
				+ coordinates.getLatitudeE6() + ','
				+ coordinates.getLongitudeE6() + ']';
	}

	/**
	 * Tells whether a line stops here
	 */
	public boolean stopsHere(Line line) {
		// Don't trust in contains()
		for (Line thisLine : lines) {
			if (thisLine.getReference().equals(line.getReference()))
				return true;
		}
		return false;
	}
}
